import java.util.Scanner;

/**
 * @author caesar
 * @date 2025/6/30
 * @apiNote
 */
//输入两个正整数m和n，求其最大公约数和最小公倍数

public class homework1_5 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        //判断是否为正整数
        int m;
        while (true) {
            System.out.print("请输入正整数m：");
            m = input.nextInt();
            if (m > 0) break;
            else {
                System.out.println("输入不正确，请重新输入正整数！");
            }
        }
        int n;
        while (true) {
            System.out.print("请输入正整数n：");
            n = input.nextInt();
            if (n > 0) break;
            else {
                System.out.println("输入不正确，请重新输入正整数！");
            }
        }
        int max = m > n ? m : n;
        int min = m < n ? m : n;
        int maxyue = 0;
        int minbei = 0;
        for (int i = 1; i <= min; i++) {
            if (max % i == 0 && min % i == 0) {
                maxyue = i;
            }
        }
        System.out.println(m + "和" + n + "的最大公约数为：" + maxyue);
        minbei = (max * min) / maxyue;
        System.out.println(m + "和" + n + "的最小公倍数为：" + minbei);
        input.close();
    }
}
